package com.v1.web.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.v1.cache.CategoryCache;
import com.v1.lo.BaseLO;
import com.v1.lo.Statement;
import com.v1.model.Category;
import com.v1.model.Item;

public class SlideShowAction extends BaseAction {

	public ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request,
			HttpServletResponse response) throws Exception {

		Integer categoryid = getInteger(request, "categoryid");
		CategoryCache categoryCache = (CategoryCache) getBean("CategoryCache");
		if (categoryid == 0 || !categoryCache.contains(categoryid)) {
			return INDEX;
		}

		Category category = categoryCache.get(categoryid);
		setAttribute(request, "category", category);

		Item cond = new Item();
		cond.setCategoryid(categoryid);
		// int itemid = getInteger(request, "itemid");
		// cond.setItemid(itemid);
		BaseLO lo = (BaseLO) getBean("BaseLO");
		List<Item> items = lo.queryForList(cond, Statement.Item_getItem);
		setAttribute(request, "items", items);

		return mapping.findForward("slideshow");
	}

}